/*
ID:luongho3
LANG:C++
TASK:fact4
*/
#include <iostream>
#include <fstream>
#define THRESHOLD 100000
using namespace std;
ifstream fin("fact4.in");
ofstream fout("fact4.out");
int n;
int main() {
    fin >> n;
    int temp = 1;
    int i;
    for (i=2;i<=n;++i) {
        temp *= i;
        while (temp%10 == 0) {
              temp /= 10;
        }
        temp %= THRESHOLD;
    }
    fout << temp%10 << "\n";
    return 0;
}
